#!/bin/bash

# Input parameters: Image file name (any type, png, gif, jpg...)
# Example:
#
# ./plot.sh <plot range> kapmap.gif

range=$1
range2=$2

echo "
set xlabel 'arcsec'

set xrange [-$range:$range]
set yrange [-$range:$range]

p  'grid.dat' w l lc rgb 'gray'  t 'grid', 'cc.dat' w l lc rgb 'red' t 'Critics'

p  'grid_kapmap.dat' w l lc rgb 'gray'  t 'grid', 'cc_kapmap.dat' w l lc rgb 'red' t 'Critics'

set xrange [-$range2:$range2]
set yrange [-$range2:$range2]

p  'grid.dat' u 3:4 w l lc rgb 'gray'  t 'grid', 'cc.dat' u 3:4 w l lc rgb 'red' t 'Caustics'

p  'grid_kapmap.dat' u 3:4 w l lc rgb 'gray'  t 'grid', 'cc_kapmap.dat' u 3:4 w l lc rgb 'red' t 'Caustics'

set terminal png font '/usr/share/fonts/truetype/freefont/FreeSans.ttf' 13 size 525,500

set xrange [-$range:$range]
set yrange [-$range:$range]

set output 'nfw_crit.png'

p  'grid.dat' w l lc rgb 'gray'  t 'grid', 'cc.dat' w l lc rgb 'red' t 'Critics'
set output 'kapmap_crit.png'

p  'grid_kapmap.dat' w l lc rgb 'gray'  t 'grid', 'cc_kapmap.dat' w l lc rgb 'red' t 'Critics'

set xrange [-$range2:$range2]
set yrange [-$range2:$range2]

set output 'nfw_caustic.png
p  'grid.dat' u 3:4 w l lc rgb 'gray'  t 'grid', 'cc.dat' u 3:4 w l lc rgb 'red' t 'Caustics'

set output 'kapmap_caustic.png
p  'grid_kapmap.dat' u 3:4 w l lc rgb 'gray'  t 'grid', 'cc_kapmap.dat' u 3:4 w l lc rgb 'red' t 'Caustics'

" | gnuplot -persist

   montage nfw_crit.png kapmap_crit.png -geometry '400x400+2+2>' compare_crit.png
   montage nfw_caustic.png kapmap_caustic.png -geometry '400x400+2+2>' compare_caustic.png


